<?php
/**
 * Created by PhpStorm.
 * User: zhangrongxiang
 * Date: 2018/2/13
 * Time: 下午2:32
 */

$arr = [1,2];
$arr2 = array_pad($arr,5,0);
//[0] => 1, [1] => 2
print_r($arr);
//[0] => 1, [1] => 2, [2] => 0, [3] => 0, [4] => 0,
print_r($arr2);
//[0] => 0, [1] => 0, [2] => 0, [3] => 1, [4] => 2,
$arr3 = array_pad($arr,-5,0);
print_r($arr3);

$arr4 = array_pad([],2,0);
//[0] => 0[1] => 0
print_r($arr4);